package com.itheima.config;

import com.itheima.controller.interceptor.ProjectInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * ClassName: SpringMvcSupport
 * Package: com.itheima.config
 * Description:
 *
 * @Auther gongkaiming
 * @Create 2024/11/29 20:50
 * @Version 1.0
 */
@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {

    @Autowired
    private ProjectInterceptor projectInterceptor;

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/page/**").addResourceLocations("page/");
        registry.addResourceHandler("/css/**").addResourceLocations("css/");
        registry.addResourceHandler("/js/**").addResourceLocations("js/");
        registry.addResourceHandler("/plugins/**").addResourceLocations("plugins/");

    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(projectInterceptor).addPathPatterns("/books");
    }
}
